[r14]: / branches / PackMLState / Display_Escape_PLC / Plc Logic / Application / Function Blocks / Puzzle / ByteSwapPuzzleStateMachine / svnobj  Maximize  Restore  History

Download this file

92 lines (90 with data), 23.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
IF NOT xInit THEN	
	UM				(		sName := 'Normal Operation', 
							dwAllowsLeavingFromStates := PACK_ML.State.Stopped OR PACK_ML.State.Aborted OR PACK_ML.State.Idle, 
		IF SysStrCmp(Client.sCommandToPLC, Client.LockCommands[0]) =  0 THEN		
			overrideKey := TRUE;			
		ELSIF SysStrCmp(Client.sCommandToPLC, 'UnSuspend') =  0 THEN		
			UnSuspend();
		
	END_CASE
	Client.iCommandToPLC := 0;
	Client.sCommandToPLC := '';
	Client.bReadyToPLC := FALSE;
CASE UM.CurrentState OF
PACK_ML.State.Stopped:
	;
PACK_ML.State.Aborted:
PACK_ML.State.Idle:
PACK_ML.State.Complete :	
PACK_ML.State.Execute :
	CASE Client.Mode OF
		Mode.Mode1:
			IF puzzleTimer.iProcess = 10 THEN
				SendCommand(Command := CommandType.Hint ,Value := '36 9 34');	
			IF puzzleTimer.iProcess = 40 THEN	
					SendCommand(Command := CommandType.Media ,Value := 'https://en.wikipedia.org/wiki/Bit_numbering#Least_significant_bit');
				END_IF
			END_IF				
			CASE Client.Level OF
				Level.Beginner:
					ShadowInByte := ROL(InByte,0);
				Level.Placeholder1:
					ShadowInByte := ROL(InByte,2);
				Level.Intermediate:
					ShadowInByte := ROL(InByte,4);
				Level.Placeholder2:
					ShadowInByte := ROL(InByte,6);
				Level.Advanced:
					ShadowInByte := ROL(InByte,8);
			END_CASE
		Mode.Mode2:
					SendCommand(Command := CommandType.Media ,Value := 'https://en.wikipedia.org/wiki/Endianness#Files_and_byte_swap');				
			temp.7 := InByte.0;
			temp.6 := InByte.1;
			temp.5 := InByte.2;
			temp.4 := InByte.3;
			temp.3 := InByte.4;
			temp.2 := InByte.5;
			temp.1 := InByte.6;
			temp.0 := InByte.7;
			ShadowInByte := temp; 	
	CASE Client.ActualStep OF
		0:	// Waiting for key.
				Client.ActualStep := Client.ActualStep + 10;
				// Turn on the screen.
		10: // Check solution
			IF ton.Q THEN
					LocalOutByte := 0;
					LocalOutByte := LocalOutByte + 1;
				Client.ActualStep := Client.ActualStep + 5;
			IF CheckSolution() THEN
			ELSE
			IF NOT DI_Key_switch AND NOT overrideKey THEN				
				ViewIndex := 1;
		20:
				Client.ActualStep := Client.ActualStep + 10;		 
				IF ShadowInByte = OutByte THEN
					Client.ActualStep := 10;
					Client.ActualStep := 0;
					// Turn off the screen.
		40:
				Client.ActualStep := Client.ActualStep + 10;	 
		60:
		70:	
				OutByte := 8;
		100:
		110:	
				OutByte := 32;
		140:
		150:	
				OutByte := 128;
		170:	
				StateComplete();
	ViewIndex := 1;
	LocalInByte := 0;
	ShadowInByte := 0;
	StateComplete();
PACK_ML.State.Completing :
PACK_ML.State.Stopping:
END_CASE
IF NOT x_EmergencyGF AND x_EmergencyFF THEN
	Abort();